home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 4 / Apprentice-Release4.iso / Source Code / Libraries / SAT 2.3.7 / Demos / Demo ƒ / StepPlatform Demo ƒ / VBLSync.c < prev   
Encoding:
C/C++ Source or Header  |  1995-05-14  |  1.1 KB  |  53 lines  |  [TEXT/KAHL]

  1. #include <Retrace.h>
  2. #include <Start.h>
  3.  
  4. Boolean InstallVBLCounter(void);
  5. Boolean RemoveVBLCounter(void);
  6. pascal int VBLCounterProc(void);
  7.  
  8. typedef struct {
  9.     VBLTask            task;
  10.     short                videoslot;
  11.     long                count;
  12. } VBLCounterRec;
  13.  
  14. VBLCounterRec VBLCounter;
  15.  
  16. /************************************************************/
  17.  
  18. Boolean InstallVBLCounter(void)
  19. {
  20.     DefVideoRec            VBLVideoDefault;
  21.  
  22.     VBLCounter.task.vblAddr = VBLCounterProc;
  23.     VBLCounter.task.qType = vType;
  24.     VBLCounter.task.vblCount = 1;
  25.     VBLCounter.task.vblPhase = 0;
  26.     
  27.     GetVideoDefault(&VBLVideoDefault);
  28.     VBLCounter.videoslot = VBLVideoDefault.sdSlot;
  29.  
  30.     VBLCounter.count = 0;
  31.     
  32.     return (SlotVInstall((QElemPtr)&VBLCounter.task, VBLCounter.videoslot)== noErr);
  33. }
  34.  
  35. /************************************************************/
  36.  
  37. Boolean RemoveVBLCounter(void)
  38. {
  39.     return (SlotVRemove((QElemPtr)&VBLCounter.task, VBLCounter.videoslot) ==noErr);
  40. }
  41.  
  42. /************************************************************/
  43.  
  44. pascal int VBLCounterProc(void)
  45. {
  46.     asm {    
  47.         MOVE.W    #1, OFFSET(VBLCounterRec, task.vblCount) (A0)
  48.         ADDQ.L    #1, OFFSET(VBLCounterRec, count) (A0)
  49.     }
  50.     
  51.     return(true);
  52. }
  53.